package com.pjj.boardservice.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pjj.boardservice.Entity.Board;
import com.pjj.boardservice.mapper.BoardMapper;
import com.pjj.boardservice.service.BoardService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 76004
 * @apiNote
 * @date 2023/2/7 17:06
 */
@RestController
@RequestMapping("/board")
public class BoardController {

    @Autowired
    private BoardMapper boardMapper;

    @Autowired
    private BoardService boardService;

    @ApiOperation(value = "添加公告")
    @PostMapping("/insertBoard")
    public Object insertBoard(@RequestBody Board board){
        return boardService.insertBoard(board);
    }

    @ApiOperation(value = "按照id查询公告")
    @GetMapping("/selectById")
    public Object selectById(int boardId){
        return boardService.selectById(boardId);
    }

    @ApiOperation(value = "按照id删除公告")
    @DeleteMapping("/delete")
    public Object deleteById(int boardId){
        return boardService.deleteBoardById(boardId);
    }

    @ApiOperation(value = "更新公告")
    @PutMapping("/update")
    public Object updateById(@RequestBody Board board){
        return boardService.updateBoard(board);
    }

    @ApiOperation(value = "查询所有公告")
    @GetMapping("/selectAll")
    public Object selectAll(int pageNum, int pageSize){
        return boardService.selectPage(pageNum,pageSize);
    }

    @ApiOperation(value = "查询公告数量")
    @GetMapping("/selectBoardCount")
    public Object selectBoardCount(){
        return boardService.selectBoardCount();
    }

    @GetMapping("/test")
    public Object Test(){
        return "test success!!!";
    }



}
